﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IntraVision.Web;

namespace Model
{
    partial class ScheduleDayException : IWorkingHours
    {
        public SchedulePeriod SchedulePeriod { get { return null; } }
        public WorkingHoursType Type { get { return WorkingHoursType.DayException; } }
        public int EditId { get { return Id; } }

        public string Interval { get { return "Правило действует один день: " + Date.ToDateString(); } }

        public bool IsWorkingTime(int h, int m)
        {
            if (!TimeStart.HasValue) return false;

            TimeSpan _time = new TimeSpan(h, m, 0);
            if (BreakStart.HasValue && BreakStart.Value.TimeOfDay <= _time && BreakEnd.Value.TimeOfDay > _time) return false;
            if (TimeStart.Value.TimeOfDay <= _time && TimeEnd.Value.TimeOfDay > _time) return true;

            return false;
        }
    }
}
